package com.weifangfirecontrolformal.weifangfirecontrolformal.web.web.check.checkaddrrecord;

import cn.hutool.json.JSONObject;
import com.weifangfirecontrolformal.weifangfirecontrolformal.common.base.BaseController;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.Action;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.At;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.model.RespEntity;
import com.weifangfirecontrolformal.weifangfirecontrolformal.web.service.check.checkaddrrecord.CheckaddrRecordService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 巡检痕迹控制器
 */
@Action
@RequestMapping(value="check/checkaddrRecord")
public class CheckaddrRecordController extends BaseController {
    @Resource
    public CheckaddrRecordService checkaddrRecordService;

    /**
     * 分区位置详情
     * @param
     * querytime	查询日期
     * @return
     */
    @At(value = "checkaddrRecordDetail", method = RequestMethod.GET)
    public RespEntity checkaddrRecordDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return checkaddrRecordService.checkaddrRecordDetail(jsonParam);
    }

    /**
     * 分区位置详情：app(带分页)
     * @param
     * querytime	查询日期
     * @return
     */
    @At(value = "checkaddrRecordDetailForApp", method = RequestMethod.GET)
    public RespEntity checkaddrRecordDetailForApp(@RequestBody(required = false) JSONObject jsonParam) {
        return checkaddrRecordService.checkaddrRecordDetailForApp(jsonParam);
    }

    /**
     * 巡检巡查详情
     * @param   rfid：RFID码
     * @return
     */
    @At(value = "checkDetail", method = RequestMethod.GET, param = { "rfid"})
    public RespEntity checkDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return checkaddrRecordService.checkDetail(jsonParam);
    }

    /**
     * 计划详情
     * @param
     * rfid	RFID码
     * id	检查计划的id
     * @return
     */
    @At(value = "planDetail", method = RequestMethod.GET, param = { "rfid","id"})
    public RespEntity planDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return checkaddrRecordService.planDetail(jsonParam);
    }

    /**
     * 检查记录添加
     * @param
     * des    隐患描述
     * grade	隐患等级：对应字典表
     * state	状态：1 未整改 2 整改中 3 整改完成
     * haveFlag	true:有隐患  false：没有
     * rfid	RFID码
     * @return
     */
    @At(value = "add", method = RequestMethod.POST, param = { "rfid" })
    public RespEntity add(@RequestBody(required = false) JSONObject jsonParam) {
        return checkaddrRecordService.add(jsonParam);
    }

    /**
     * 巡检地址记录列表
     * @param
     * des    隐患描述
     * grade	隐患等级：对应字典表
     * state	状态：1 未整改 2 整改中 3 整改完成
     * haveFlag	true:有隐患  false：没有
     * rfid	RFID码
     * @return
     */
    @At(value = "checkaddrRecordList", method = RequestMethod.GET, param = { "rfid","querytimeStart","querytimeEnd" })
    public RespEntity checkaddrRecordList(@RequestBody(required = false) JSONObject jsonParam) {
        return checkaddrRecordService.checkaddrRecordList(jsonParam);
    }

    /**
     * 巡检记录下载
     * @param map
     * @return
     * @throws Exception
     */
    @At(value = "getCheckUpload", method = RequestMethod.GET)
    public ResponseEntity<byte[]> getCheckUpload(@RequestParam Map<String,Object> map) throws Exception {
        return checkaddrRecordService.getCheckUpload(map,request);
    }





   
}